//登录相关
import request from "@utils/request";
/**
 * 登录用手机验证码 
 * @returns {*}
 */
export function getVerificationCode(phoneNumber) {
    return request.post("/im/app/sms/login", { phoneNumber });
}

/**
 * 验证手机号登录验证码
 * @returns {*}
 */
export function loginByMobile(phoneNumber, verificationCode) {
    return request.post("/im/app/user/loginByMobile", { phoneNumber, verificationCode });
}

/**
 * 验证邮箱号登录验证码
 * @returns {*}
 */
export function loginByEmail(to, verificationCode) {
    return request.post("/im/app/user/loginByEmail", { to, verificationCode });
}


/**
 * 通用邮箱验证码
 * @returns {*}
 */
export function sendCommonEmailVcode(toEmail) {
    return request.post("/im/app/email/sendCommonEmailVcode", { toEmail });
}

/**
 * 登录用邮箱验证码 
 * @returns {*}
 */
export function loginEmail(toEmail) {
    return request.post("/im/app/email/loginEmail", { toEmail });
}

/**
 * 通用短信验证码
 * @returns {*}
 */
export function getCommonSmsVcode(phoneNumber) {
    return request.post("/im/app/sms/sendCommonSmsVcode", { phoneNumber });
}

/**
 * 绑定手机号验证码
 * @returns {*}
 */
export function bindPhoneCode(phoneNumber) {
    return request.post("/im/app/sms/binding", { phoneNumber });
}

/**
 * 发送手机换绑验证码
 * @returns {*}
 */
export function changePhoneCode(phoneNumber) {
    return request.post("/im/app/sms/change", { phoneNumber });
}

/**
 * 校验手机验证码
 * @returns {*}
 */
export function verifyCode(phoneNumber, verificationCode) {
    return request.post("/im/app/user/checkChangeMobile", { phoneNumber, verificationCode });
}

/**
 * 校验邮箱验证码
 * @returns {*}
 */
export function checkChangeEmail(emailAddr, verificationCode) {
    return request.post("/im/app/user/checkChangeEmail", { emailAddr, verificationCode });
}

/**
 * 获取助记词
 * @returns {*}
 */
export function getMnemonicWord() {
    return request.get("/im/app/user/getMnemonicWordList", {});
}

/**
 * 用户注册
 * @returns {*}
 */
export function register(data) {
    return request.post("/im/app/user/register/login", { ...data });
}

/**
 * 手机或邮箱+密码登录
 * @returns {*}
 */
export function mobileOrEmailLogin(data) {
    return request.post("/im/app/user/mobileOrEmailLogin", { ...data });
}

/**
 * 重置登录密码
 * @returns {*}
 */
export function resetLoginPassWord(data) {
    return request.post("/im/app/user/resetLoginPassWord", { ...data });
}

/**
 * 助记词登录
 * @returns {*}
 */
export function login(data) {
    return request.post("/im/app/user/login", { ...data });
}

/**
 * 校验昵称
 * @returns {*}
 */
export function checkNickNameExist(nickName) {
    return request({
        method: 'get',
        url: '/im/app/user/checkNickNameExist',
        params: {
            nickName
        }
    });
}

/**
 * 校验昵称（过滤敏感词）
 * @returns {*}
 */
export function checkNickNameHasUsed(nickName) {
    return request({
        method: 'get',
        url: '/im/app/user/checkNickNameHasUsed',
        params: {
            nickName
        }
    });
}

/**
 * 获取好友列表
 * @returns {*}
 */
export function getFriends(params) {
    return request({
        method: 'get',
        url: '/im/app/friend/getFriends',
        params,
        isLogin: true
    });
}

/**
 * 获取好友申请列表
 * @returns {*}
 */
export function requestList(data) {
    return request({
        method: 'post',
        url: '/im/app/friend/request/list',
        data,
        isLogin: true
    });
}

/**
 * 删除好友
 * @returns {*}
 */
export function friendUpdata(data) {
    return request({
        method: 'post',
        url: '/im/app/friend/update',
        data,
        isLogin: true
    });
}
/**
 * 响应好友请求
 * @returns {*}
 */
export function friendRes(data) {
    return request({
        method: 'post',
        url: '/im/app/friend/request/response',
        data,
        isLogin: true
    });
}